/*
 * Container.hpp
 *
 *  Created on: 24-11-2010
 *      Author: Przemek
 */

#pragma once

#include "Control.hpp"
#include "pch.hpp"

/*
 * Composite pattern class which is used to represent a GUI control which can have children as other
 * controls.
 */
class Container: public Control
{
	private:
		typedef std::vector<boost::shared_ptr<Control> > ControlsVector;
		ControlsVector controls;

	public:
		void add(Control* control);
		void remove(Control* control);
		// transforms point to returned control coordinates and puts them into pointInControlCoordinates
		virtual Control
		* getDeepestControlAt(const Vector& point, Vector* pointInControlCoordinates);
		virtual void draw(const ClipArea& clipArea);

	protected:
		void add(boost::shared_ptr<Control>& control);
		bool anyControlAt(const Vector& point) const;
		Control* getControlAt(const Vector& point) const;
		void drawChildren(const ClipArea& clipArea);
};
